package com.example.chapter5.bean;

import java.nio.charset.StandardCharsets;
import java.util.UnknownFormatConversionException;

public class CharactorException {
    public CharactorException(){
    }
    /**
     * 对字符进行转码处理
     * @param str 要转码的字符串
     * @return编码后的字符串
     */
    public String toString(String str){
        String text = "";
        if (str !=null && !"".equals(str)){
            try {
                text =new String(str.getBytes(StandardCharsets.UTF_8));
            }catch (UnknownFormatConversionException e){
                e.printStackTrace();
            }
            }
        return text;
    }
}
